﻿using System.Collections.Generic;
using System.Linq;

namespace WpfApplication1
{
    /// <summary>
    /// An answer is a correct answer in an assignment it contains a list of wrong answers as well
    /// </summary>
    public class Answer
    {
        public string Realanswer { get; set; }
        private List<string> bogusanswers;
        public int AnswerNumber { get; set; }

        public Answer(string answer)
        {
            Realanswer = answer;
            bogusanswers = new List<string>();
        }

        public List<string> GetBogusAnswers()
        {
            return bogusanswers;
        }

        public void AddBogusAnswer(string bogusanswer)
        {
            bogusanswers.Add(bogusanswer);
        }

        /// <summary>
        /// Removes a bogusanswer the integer is depending on the assignment type
        /// </summary>
        public void RemoveBogusAnswer(string bogusanswer, int i)
        {
            switch (i)
            {
                case 0:
                    if(bogusanswer != Realanswer)
                    {
                        bogusanswers.Remove(bogusanswer);
                    }
                    break;
                case 1:
                    char[] chars = Realanswer.ToArray();
                    var chars2 = new List<string>();
                    for (int j = 0; j < chars.Length; j++)
                    {
                        chars2.Add(chars[j].ToString());
                    }
                    if(chars2.Contains(bogusanswer) == false)
                    {
                        bogusanswers.Remove(bogusanswer);
                    }
                    break;
            }
        }
    }
}
